﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOFrameworks;
using FAQFrameworks;
using FooFun.DataElements.Dtos;
using AccessGrant.GrantFrameworks;

namespace FooFun.Web.Controls
{
    public class UserIdView : DataElementControl
    {
        public override IDataElement DataElement
        {
            get
            {
                return base.DataElement;
            }
            set
            {
                UserManager userManager = new UserManager();

                IDataElement user = userManager.GetElement(value);

                if (!user.IsEmpty)
                {

                    RoleSetQuery roleQuery = RoleSetQuery.Create();

                    PermissionQuery pQuery = PermissionQuery.Create();

                    IEnumItem role = pQuery.GetAccountByName("版主");

                    IDataElement roleSet
                        = roleQuery.ListForumOfUserInRole(
                        user as IEnumItem
                        , role);

                    foreach (IDataElement item in roleSet)
                    {
                        this.ShowContent("Manager");
                        break;
                    }
                }

                base.DataElement = user;
            }
        }
    }
}
